import { defineFakeRoute } from "vite-plugin-fake-server/client";
import { faker } from "@faker-js/faker/locale/zh_CN";

import dict from './dict'
import RP from "./util/response";

export default defineFakeRoute([{
    url: '/api/main',
    method: 'get',
    response: () => {
        return RP.ok('data');
    }
}, {
    url: '/api/dict/:type',
    method: 'get',
    response: ({ params }) => {
        const type = params.type as string;
        return RP.ok(dict[type])
    }
}, {
    url: '/api/router',
    method: 'get',
    response() {
        return RP.ok([
            {
                path: '/home',
                name: 'home',
                title: '首页',
                icon: 'home',
                action: [
                    'list:add',
                    'list:edit',
                    'list:delete',
                    'list:export',
                    'list:import',
                    'list:detail',
                ]
            }
        ]);
    },
}])
